/*
 * TPCAnim.h
 *
 *  Created on: 08.10.2012
 *      Author: caffeine
 */

#ifndef TPCANIM_H_
#define TPCANIM_H_

#include <ISceneNodeAnimator.h>
#include <ICameraSceneNode.h>

namespace irr {
namespace scene {

class TPCAnim: public irr::scene::ISceneNodeAnimator {
private:
	irr::scene::ISceneNode*rotH;
	irr::scene::ISceneNode*rotV;
	irr::f32 radius;
	irr::f32 oldX;
	irr::f32 oldY;
	irr::scene::ISceneNode*target;
	irr::scene::ICameraSceneNode*camera;
	irr::scene::ISceneManager*manager;
	bool mouseDown;
	irr::f32 needRotH;
	bool needRotHB;
	irr::f32 minRot;
public:
	bool isNeedRotate();
	void rotateTo(irr::f32 r);
	irr::f32 getRotationH();
	void setRadius(irr::f32 r);
	irr::f32 getRaduis();
	void setRotationH(irr::f32 r);
	TPCAnim(irr::scene::ISceneManager*_manager_,irr::scene::ISceneNode *_target_,irr::scene::ICameraSceneNode*_cam_);
	virtual void animateNode(irr::scene::ISceneNode*node,irr::u32 timeMs);
	virtual bool isEventReceiverEnabled() const{return true;};
	virtual bool OnEvent(const irr::SEvent& event);
    virtual void serializeAttributes(irr::io::IAttributes * out,irr::io::SAttributeReadWriteOptions * options ) const;
    virtual void deserializeAttributes(irr::io::IAttributes * in,irr::io::SAttributeReadWriteOptions * options );
    virtual irr::scene::ESCENE_NODE_ANIMATOR_TYPE getType() const {return irr::scene::ESNAT_UNKNOWN; }
    virtual irr::scene::ISceneNodeAnimator*createClone(irr::scene::ISceneNode*node,irr::scene::ISceneManager*newManager=0);
};

} /* namespace scene */
} /* namespace irr */
#endif /* TPCANIM_H_ */
